package com.taikang.hmp.hbusiness.diabetes.measure.info.action.intface;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.taikang.hmp.frame.common.TKException;
import com.taikang.hmp.frame.common.datastructre.Dto;
import com.taikang.hmp.frame.common.datastructre.support.BaseDto;
import com.taikang.hmp.frame.common.datastructre.support.ResponseDto;
import com.taikang.hmp.frame.common.web.action.BaseAction;
import com.taikang.hmp.hbusiness.diabetes.measure.info.service.IClickLikeService;

/** 
* @author qirp 
* @create date 2016年5月19日 上午10:59:45 
*/
public class ClickLikeAction extends BaseAction{
	private static final long serialVersionUID = 1L;
	private static Logger logger = LoggerFactory.getLogger(ClickLikeAction.class);
	
	private IClickLikeService clikeService;
	
	public IClickLikeService getClikeService() {
		return clikeService;
	}

	public void setClikeService(IClickLikeService clikeService) {
		this.clikeService = clikeService;
	}

	public String executeAction() {
		if ("savelikeinfo".equals(requestDto.getMethod())) { 
			logger.info("--【保存点赞信息】: method savelikeinfo --");
			return savelikeinfo();
		} else if("cancelikeinfo".equals(requestDto.getMethod())){
			logger.info("--【取消点赞信息】: method cancelikeinfo --");
			return cancelikeinfo();
		} else if("getclickcount".equals(requestDto.getMethod())){
			logger.info("--【保存点赞信息】: method getclickcount --");
			return getclickcount();
		}else {
			logger.info("executeAction 里没有配置"+ requestDto.getMethod() +"方法!");
			throw new TKException("no support method:" + requestDto.getMethod());
		}
	}
	
	/**
	 * 保存点赞信息
	 * @return
	 */
	public String savelikeinfo(){
		ResponseDto responseDto=new ResponseDto();
		Dto paramDto = requestDto.getRequestlist().get(0);
		paramDto = super.appendRequestBase(paramDto, requestDto);
		
		String flag = clikeService.savelikeinfo(paramDto);
		
		super.setDataMap(responseDto);
		return SUCCESS;
	}
	/**
	 * 取消点赞信息
	 * @return
	 */
	public String cancelikeinfo(){
		ResponseDto responseDto=new ResponseDto();
		Dto paramDto = requestDto.getRequestlist().get(0);
		paramDto = super.appendRequestBase(paramDto, requestDto);
		
		String flag = clikeService.cancelikeinfo(paramDto);
		
		super.setDataMap(responseDto);
		return SUCCESS;
	}
	/**
	 * 获取点赞统计
	 * @return
	 */
	public String getclickcount(){
		ResponseDto responseDto=new ResponseDto();
		Dto paramDto = requestDto.getRequestlist().get(0);
		paramDto = super.appendRequestBase(paramDto, requestDto);
		
		Dto result = clikeService.getclickcount(paramDto);
	    Dto resultDto = new BaseDto();
		resultDto.put("resultlist", result);
		responseDto.pushResultDto(resultDto);
		
		super.setDataMap(responseDto);
		return SUCCESS;
	}
}
